package com.jianyun.jyzs.presenter;

import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter;
import com.jianyun.jyzs.dao.AnnouncementDao;
import com.jianyun.jyzs.model.AnnouncementModel;
import com.jianyun.jyzs.model.imdoel.IAnnouncementsModel;
import com.jianyun.jyzs.view.iview.IAnnouncementsView;

import java.util.HashMap;

/**
 * Created by yangshijun on 2018/5/29.
 */

public class AnnouncementPresenter extends MvpBasePresenter<IAnnouncementsView> {

    /**
     * 获取通知公告列表
     *
     * @param dao
     * @param map
     */
    public void getAnnouncementList(AnnouncementDao dao, HashMap<String, String> map) {
        if (!isViewAttached()) return;
        getView().showLoading();
        AnnouncementModel.getInstance().getAnnouncementList(dao, map, new IAnnouncementsModel.OnGetAnnoucemntListener() {
            @Override
            public void onSuccess(int size) {
                getView().hintLoading();
                getView().onSuccess(size);
            }

            @Override
            public void onFaile(String msg) {
                getView().hintLoading();
                getView().onFaile(msg);
            }
        });

    }

    /**
     * 获取通知公告列表
     *
     * @param PageIndex
     * @param PageSize
     */
    public void getAnnouncement(AnnouncementDao dao,String enterpriseCode,String userId,int PageIndex, int PageSize) {
        if (!isViewAttached()) return;
        getView().showLoading();
        AnnouncementModel.getInstance().getAnnouncement(dao,enterpriseCode,userId,PageIndex, PageSize, new IAnnouncementsModel.OnGetAnnoucemntListener() {
            @Override
            public void onSuccess(int size) {
                getView().hintLoading();
                getView().onSuccess(size);
            }

            @Override
            public void onFaile(String msg) {
                getView().hintLoading();
                getView().onFaile(msg);
            }
        });

    }
}
